home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_200
/
213_01
/
xcr.c
< prev
next >
Wrap
Text File
|
1980-01-01
|
23KB
|
1,057 lines
/* XCR.C VERS:- 01.00 DATE:- 09/26/86 TIME:- 09:37:34 PM */
/*
%CC1 $1.C -O -X -E4000
%CLINK $1 -S -E4000
%DELETE $1.CRL
*/
/*
Description:
Cross-reference utility, from cug distribution disk.
Minor modification:
added check on characters of output per line (char_count),
to obtain correct pagination.
By J.A. Rupley, Tucson, Arizona
Coded for BDS C compiler, version 1.50a
*/
/* HEADER: CUG120.25;
TITLE: XC;
VERSION: 1.0;
DATE: 00/00/1982;
DESCRIPTION: "A cross-reference utility for C-programs.
It has the ability to handle nested include files to
a depth of 8.";
KEYWORDS: C programming,concordance generator;
SYSTEM: CP/M;
FILENAME: XC.C;
CRC: 3D48;
AUTHORS: Phillip N. Hisley;
COMPILERS: BDS C;
*/
/***********************************************************/
/* */
/* XC - A 'C' Concordance Utility */
/* */
/* Version 1.0 January, 1982 */
/* */
/* Copyright (c) 1982 by Philip N. Hisley */
/* */
/* Released for non-commercial distribution only */
/* */
/* Abstract: */
/* */
/* 'XC' is a cross-reference utility for 'C' programs. */
/* Its has the ability to handle nested include files */
/* to a depth of 8 levels and properly processes nested */
/* comments as supported by BDS C. Option flags support */
/* the following features: */
/* */
/* - Routing of list output to disk */
/* - Cross-referencing of reserved words */
/* - Processing of nested include files */
/* - Generation of listing only */
/* */
/* Usage: xc <filename> <flag(s)> */
/* */
/* Flags: -i = Enable file inclusion */
/* -l = Generate listing only */
/* -r = Cross-ref reserved words */
/* -o <filename> = Write output to named file */
/* */
/* */
/* ------------------------------------------------- */
/* */
/* Compiliation Instructions - BDS C V1.42 */
/* */
/* XC.C utilizes the dynamic storage allocation */
/* scheme provided by BDS C .. this option must be */
/* enabled per the instructions in BDSCIO.H */
/* */
/* The -o and the -e options are used to maximize */
/* the execution speed of XC. */
/* */
/* cc1 xc.c -o -e3560 */
/* clink xc -s -e3560 */
/* */
/* Note: The location of the externals (-e3560) */
/* is valid for version 1.0 of XC.C .. any */
/* changes to XC.C which increase the size */
/* of the generated code will require that */
/* -e <xxxx> be resized .. also use of a */
/* version of BDS C other than V1.42 may */
/* alter the location of the external data */
/* .. handle with care! */
/* */
/* Resizing Procedure: */
/* */
/* 1. Compile/link XC with -o option: */
/* */
/* cc1 XC.C -o */
/* clink XC -s */
/* */
/* The link map will indicate the address */
/* at which external data starts .. in the */
/* case of XC V1.0/BDS C V1.42 this becomes */
/* 3821h */
/* */
/* 2. Re-compile/link XC with the -o option */
/* and the -e option using the external */
/* data address obtained from step 1. */
/* */
/* cc1 XC.C -o -e3821 */
/* clink XC -s -e3821 */
/* */
/* 3. Use of the -e option in step 2 will cause */
/* the size of the generated code to become */
/* smaller .. re-compile/link adjusting the */
/* external data address to just above the */
/* end of the code. */
/* */
/* cc1 XC.C -o -e3560 */
/* clink XC -s -e3560 */
/* */
/* ------------------------------------------------- */
/* */
/* Please report bugs/fixes/enhancements to: */
/* */
/* Philip N. Hisley */
/* 548H Jamestown Court */
/* Edgewood, Maryland 21040 */
/* (301) 679-4606 */
/* */
/* */
/***********************************************************/
#include "bdscio.h"
#define LINELENGTH 63
#define MAX_REF 5 /* maximum refs per ref-block */
#define MAX_LEN 20 /* maximum identifier length */
#define MAX_WRD 749 /* maximum number of identifiers */
#define MAX_ALPHA 53 /* maximum alpha chain heads */
#define REFS_PER_LINE 8 /* maximum refs per line */
#define LINES_PER_PAGE 60
#define FF 0x0C /* formfeed */
struct id_blk
{
char id_name[MAX_LEN];
struct id_blk *alpha_lnk;
struct rf_blk *top_lnk;
struct rf_blk *lst_lnk;
}
oneid;
struct rf_blk
{
int ref_item[MAX_REF];
int ref_cnt;
}
onerf;
struct id_blk *id_vector[MAX_WRD];
struct alpha_hdr
{
struct id_blk *alpha_top;
struct id_blk *alpha_lst;
}
;
struct alpha_hdr alpha_vector[MAX_ALPHA];
int char_count;
int linum; /* line number */
int edtnum; /* edit line number */
int fil_cnt; /* active file index */
int wrd_cnt; /* token count */
int pagno; /* page number */
int id_cnt; /* number of unique identifiers */
int rhsh_cnt; /* number of conflict hits */
int filevl; /* file level */
int paglin; /* page line counter */
int prt_ref;
char act_fil[MAX_LEN];
char lst_fil[MAX_LEN];
char gbl_fil[MAX_LEN];
char l_buffer[BUFSIZ];
int i_flg, o_flg, r_flg, l_flg;
main(argc, argv)
int argc;
char **argv;
{
char *arg;
if (argc < 2)
use_err();
i_flg = r_flg = o_flg = l_flg = FALSE;
strcpy(gbl_fil, *++argv);
--argc;
if (gbl_fil[0] == '-')
use_err();
while (--argc != 0)
{
if (*(arg = *++argv) == '-')
{
switch (*++arg)
{
case 'I' :
i_flg++;
break;
case 'R' :
r_flg++;
break;
case 'L' :
l_flg++;
break;
case 'O' :
{
o_flg++;
if (--argc == 0)
use_err();
strcpy(lst_fil, *++argv);
if (lst_fil[0] == '-')
use_err();
break;
}
default :
use_err();
}
}
else
use_err();
}
if (o_flg)
{
if (fcreat(lst_fil, l_buffer) == ERROR)
{
printf("ERROR: Unable to create list file - %s\n", lst_fil);
exit(0);
}
printf("XC ... 'C' Concordance Utility v1.0\n\n");
}
_allocp = NULL; /* initialize memory allocation pointer */
prt_ref = FALSE;
for (linum = 0; linum < MAX_WRD; linum++)
{
id_vector[linum] = NULL;
}
for (linum = 0; linum < MAX_ALPHA; linum++)
{
alpha_vector[linum].alpha_top =
alpha_vector[linum].alpha_lst = NULL;
}
fil_cnt = wrd_cnt = linum = 0;
char_count = 1;
filevl = paglin = pagno = edtnum = 0;
id_cnt = rhsh_cnt = 0;
proc_file(gbl_fil);
if (!l_flg)
{
prnt_tbl();
printf("\nAllowable Symbols: %d\n", MAX_WRD);
printf("Unique Symbols: %d\n", id_cnt);
}
if (o_flg)
{
nl();
if (fprintf(l_buffer, "%c", CPMEOF) == ERROR)
lst_err();
fflush(l_buffer);
fclose(l_buffer);
}
}
strcmp(s, t)
char s[], t[];
{
int i;
i = 0;
while (s[i] == t[i])
if (s[i++] == '\0')
return (0);
return (s[i] - t[i]);
}
char *strcpy(s1, s2)
char *s1, *s2;
{
char *temp;
temp = s1;
while (*s1++ = *s2++)
;
return (temp);
}
lst_err()
{
printf("\nERROR: Write error on list output file - %s\n",
lst_fil);
exit(0);
}
use_err()
{
printf("\nERROR: Invalid parameter specification\n\n");
printf("Usage: xc <filename> <flag(s)>\n\n");
printf("Flags: -i = Enable file inclusion\n");
printf(" -l